home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / GENetReleaseƒ / Extras / Paths.h < prev   
Text File  |  1994-03-07  |  3KB  |  111 lines

  1. /*
  2.     Paths.h
  3.     
  4.     Paths routines for Graphic Elements
  5.     
  6.     Copyright 1993 by Al Evans
  7.     
  8.     11/10/93
  9.     
  10. */
  11.  
  12. //Load precompiled headers if in MPW
  13. #ifdef applec
  14. #ifndef __cplusplus
  15. #ifndef PRELOAD
  16. #pragma load "::ToolKit.precompile"
  17. #define PRELOAD
  18. #endif
  19. #endif
  20. #endif
  21.  
  22. /*
  23.     Another quick hack -- showing how frames and positions of Graphic Elements
  24.     might be changed by a path interpreter.
  25. */
  26.  
  27. /*
  28.     A simple path system for programmed animation. A PathRec contains a
  29.     pointer to a sequence of PathEntries and fields to hold the results
  30.     of processing those PathEntries.
  31.     
  32.     The FrameSeqGraphic which uses paths calls InitPath to initialize
  33.     the PathRec, then calls GetNextStep during its AutoChangeProc update
  34.     its PathRec. On return from GetNextStep, it changes frames if 
  35.     PathRec.currFrame is non-zero and moves if PathRec.currXMove or
  36.     PathRec.currYMove is non-zero.
  37.     
  38.     Each PathEntry is one step in the path. Each PathEntry has a command,
  39.     a parameter, and x value, and a y value. Their effects on the fields
  40.     of the PathRec depend on the command:
  41.         
  42.         absMotionCmd: 
  43.                 PathRec.currFrame = param;
  44.                 PathRec.currXMove = xVal;
  45.                 PathRec.currYMove = yVal;
  46.         
  47.         relMotionCmd:
  48.                 PathRec.currFrame = param;
  49.                 PathRec.currXMove += xVal;
  50.                 PathRec.currYMove += yVal;
  51.                 
  52.     Paths can also contain control commands:
  53.     
  54.         gotoCmd:
  55.                 Reset the current step in the path to (param) and
  56.                 process the PathEntry found there.
  57.         resetCmd:
  58.                 Reset the current step in the path to zero. Must
  59.                 be included as the last step in each path.
  60.         repeatCmd:
  61.                 Only meaningful before a relMotionCmd. Causes the
  62.                 next command to be repeated (param) times. If this
  63.                 command includes a frame change, the frame is changed
  64.                 only on the first execution.
  65. */
  66.  
  67. typedef struct {
  68.     signed char        command;
  69.     unsigned char    param;
  70.     signed char        xVal;
  71.     signed char        yVal;
  72. }    PathEntry, *PathEntryPtr;
  73.  
  74. typedef struct {
  75.     short            currStep;
  76.     short            currFrame;
  77.     short            currXMove;
  78.     short            currYMove;
  79.     short            count;
  80.     short            sp;
  81.     short            stack[16];
  82.     PathEntryPtr    path;
  83. } PathRec, *PathRecPtr;
  84.  
  85. typedef enum {
  86.         absMotionCmd    =     (signed char) 0x20,
  87.         relMotionCmd    =    (signed char) 0x21,
  88.         //commands < 0 manipulate path pointer
  89.         repeatCmd        =    (signed char) 0xD1,
  90.         goToCmd            =    (signed char) 0xE0,
  91.         goSubCmd        =    (signed char) 0xE1,
  92.         returnCmd        =    (signed char) 0xE2,
  93.         resetCmd        =    (signed char) 0xFF
  94. } PathCommand;
  95.     
  96. #ifdef __cplusplus
  97. extern "C" {
  98. #endif
  99.  
  100. void InitPath(PathRecPtr path);
  101.  
  102. void GetNextStep(PathRecPtr path);
  103.  
  104. void DoPathGoTo(PathRecPtr path, short gotoStep);
  105.  
  106. void DoPathGoSub(PathRecPtr path, short subRtnStep);
  107.  
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111.